import numpy as np

def _mean_nz(mat):
    val = np.sum(mat) / (np.where(mat > 0)[0]).size
    return val
